package nl.hr.cmi.opleiding;

import java.util.List;

import nl.hr.cmi.opleiding.utils.PinItemizedOverlay;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MapView.LayoutParams;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class Locatie extends MapActivity {
	MapView mapView;
	MapController mc;
	GeoPoint p;
	LinearLayout zoomLayout; 
	Drawable pindrawable;

	private final String coordinates[] = { "51.91007", "4.46252" };

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.locatie);
		zoomLayout = (LinearLayout) findViewById(R.id.zoom);

		mapView = (MapView) findViewById(R.id.mapView);
		mapView.setStreetView(true);
		
		View zoomView = mapView.getZoomControls();
		zoomLayout.addView(zoomView, new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		mapView.displayZoomControls(true);
		
		List<Overlay> mapOverlays = mapView.getOverlays();
		pindrawable = this.getResources().getDrawable(R.drawable.pinpoint);
		PinItemizedOverlay itemizedoverlay = new PinItemizedOverlay(pindrawable,
				this);

		double lat = Double.parseDouble(coordinates[0]);
		double lng = Double.parseDouble(coordinates[1]);

		p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
		OverlayItem overlayitem = new OverlayItem(p, "Hogeschool Rotterdam",
				"Locatie: Academieplein");

		itemizedoverlay.addOverlay(overlayitem);
		mapOverlays.add(itemizedoverlay);

		mc = mapView.getController();
		mc.animateTo(p);
		mc.setZoom(18);

		mapView.invalidate();
	}

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
}
